package stream._01introduction;

import stream.bean.Student;
import stream.bean.StudentList;

import java.util.List;
import java.util.TreeSet;
import java.util.function.Consumer;

public class Demo2 {
    public static void main(String[] args) {
        //对学生列表进行处理，得到来自北京并且身高最高的三位同学
        List<Student> studentList = new StudentList().studentList;

        //从数据源中站到北京的同学
//        TreeSet<Student> students = new TreeSet<>(new Comparator<Student>() {
//            @Override
//            public int compare(Student o1, Student o2) {
//                return o2.getHeight() - o1.getHeight();
//            }
//        });
        TreeSet<Student> students = new TreeSet<>((o1, o2) -> o2.getHeight() - o1.getHeight());
        studentList.forEach(new Consumer<Student>() {
            @Override
            public void accept(Student student) {
                if(student.getAddress() == Student.Address.BJ) {
                    students.add(student);
                }
            }
        });
        Student student1 = students.pollFirst();
        Student student2 = students.pollFirst();
        Student student3 = students.pollFirst();
        System.out.println(student1);
        System.out.println(student2);
        System.out.println(student3);
    }
}
